package com.aos.util;

import lombok.Data;

import java.util.Map;

/**
 * @ClassName Result
 * @Description:返回结果类
 * @Author wumingwang
 * @Date 2018/9/9 22:27
 * @Version 1.0
 */
@Data
public class Result {
    private Integer status;
    private String message;
    private Object data;

    public static Result error() {
        return error(500, "未知异常，请联系管理员");
    }

    public static Result error(String msg) {
        return error(500, msg);
    }

    public static Result error(int code, String msg) {
        Result r = new Result();
        r.setStatus(code);
        r.setMessage(msg);
        return r;
    }

    public static Result ok(int code,String msg,Object data) {
        Result r = new Result();
        r.setStatus(code);
        r.setMessage(msg);
        r.setData(data);
        return r;
    }

    public static Result ok(String msg) {
        return ok(200,msg,null);
    }

    public static Result ok() {
        return ok(200,"",null);
    }

    public static Result ok(Object data){
        return ok(200,"",data);
    }
}
